home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Svd Messageboard Arcive / ephemery / data / MBPREP.ZIP / MSG2.PL < prev    next >
Encoding:
Text File  |  1999-04-26  |  4.2 KB  |  130 lines

  1. #this is only the single-messages filter
  2.  
  3. #$IN = $ARGV[0] eq '' ? "-" : $ARGV[0];
  4. #open(IN) || die "can't open $IN";
  5.  
  6. ####require "msgflt.pl";
  7. #uses $skip, $slave, $nothdr
  8. #$slave= 1;      #is current file slave or main-one
  9. $skip=0;        #state: skipping or no
  10. $nothdr=0;      #recording mode; starts with recording header
  11.  
  12. sub init { $skip= $nothdr=0; }
  13.  
  14. sub filtline {          #return 1 if line should be skipped
  15.    if (m|\">Back to main board</A>|i) {
  16.     $skip=1;
  17. #     $skip=0 if $skip==1;      #stop skipping
  18. #     $skip=1 if $skip==2;      #if skipping inside-message mssg-thread
  19. ###   $slave=1;
  20. ###   s|http:.+mbs\.cgi.acct\=mb(\d{6})\"|mb$1.htm\"|;
  21. #     s|<A HREF=\".+mb(\d{6}).*\"|<A HREF=\"mb$1.htm\"|;
  22. #     s|<B>||; s|</B>||;
  23.     }
  24.  
  25.    return 1 if m|<!--|;                 #skip comments
  26.    return 1 if m|^<blockquote>|;        #skip whole heading
  27.    return 1 if m/[^<]<img src="/;        #skip any line with pictures
  28.    if (m|\"#POSTNEW\"|) { $nothdr++; return 1; }    #skip goto-post-new-message
  29.  
  30.         #skip listbox-menu-header:
  31.    return 1 if m|javascript:if\(confirm\(\'|; #works if teleportPro used  #http://www.insidetheweb.com/
  32.    return 1 if m|[^<]<option|;                      #skip listbox-menu-0
  33.    return 1 if m|^<option|;                         #skip listbox-menu
  34.    return 1 if m|[^<]<input type=\"submit\"|;       #skip listbox-menu-footer
  35.  
  36.    if (m|</SCRIPT>|) { $skip = 0; return 1; }   #end skipping javascript
  37.    if (m|</body>|)   { $skip = 0; }             #end skipping everything NOW
  38.  
  39.    $skip=1  if m|<SCRIPT language=\"javascript\">|;     #start skipping javascript
  40. #  $skip=1  if m|<FORM ACTION=|;                #start skipping newmsg form
  41.    $skip=1  if m|<center><table border=3><tr><td>|;     #start skipping newmsg form
  42.    $skip=2  if m|[^>]>Message thread:<|i;       #start skipping thread-view
  43.  
  44.    $skip=0  if m|</head>|i;             #stop skipping
  45.  
  46.    return 1 if $skip;
  47.    $skip=1  if m|>Back to main board</A>|;      #start skiping again/new-mssg table
  48. #  $skip=1  if m|^ *</TITLE>|i;         #start skiping after eo title
  49.    $skip=1  if m|[^<]</TITLE>|i;        #start skiping after eo title
  50.    return 1 if /<title>/i;      #skip title also
  51.    s|<font [^>]*>||gi; s|</font>||gi;
  52.    s|</*head>||gi;
  53.    s|</a>||gi if !/[^<]*<a/i;   #there's an hanging /a in ... writes:
  54.    s| TEXT="#......" LINK="#......">|>|i;
  55.    return 1 if $_ eq "\n";
  56.    return 0;
  57. }
  58. ###1;      #needed by "require()" operator
  59. ####eo require
  60.  
  61. #while (<IN>) {            #if using (<>) $ARGV is current file's name
  62. #    next if &filtline ; print;
  63. ##   $x =  &filtline ; print "$skip:$x:$_";
  64. #}
  65. #close IN;
  66.  
  67. sub filename {
  68.    if ($x eq '') {
  69.      print "$c!!!\n";
  70.      $x = $c;
  71.      $x =~ s/^.*\\//;
  72.      $x =~ s/\..*$//;
  73.      print "$x\n";
  74.     }
  75.    if ($x ne '') {
  76.      $x = ">$x.HTM";
  77.      open(x) || die "$! $x";
  78.      for ($j=0;$j<$i;$j++) { print x $z[$j]; }
  79.      close(x);
  80.    }
  81. }
  82.  
  83.  
  84. $x='';
  85. $c='';
  86. $i=0;
  87. while (<>) {
  88.    if (/\"MyNum\"/) {
  89.      $x = $_;
  90.      $x =~ s/<INPUT NAME=\"MyNum\" TYPE=\"hidden\" VALUE=\"//i;
  91.      $x =~ s/\".*\s*//;
  92.      $x = substr($x,-8);
  93.     }
  94.    s/\ \;/ /gi; s/nbsp;//gi;
  95.    s/ *<BR>/<BR>\n/gi; s/\n\n/\n/g;
  96. #  s|<font size=\".{1,2}\">||gi;
  97. #  s|<font size=\".{1,2}\" face=\"arial,helvetica\">||gi;
  98.  
  99.    if (m|^</center>\s*$|i && 5==$nothdr) { $skip=0; $nothdr=0; next; }   #stop skiping/topmost listbox
  100.    if (/^<table width=.+ cellpadd/i && !$nothdr) { $skip=1; $nothdr=5; next; }
  101.    s/^<center>\s*$//i;
  102.  
  103.    s|</*p>||gi;
  104.    s|<ul>|<br>|gi; s|</ul>||gi;
  105. #  s|<hr *size=[^>]*>|<hr>|gi;          #no hr's
  106.    next if m|^ *<hr *size=[^>]*>|i;
  107.    next if m|^ *<hr>|i;
  108.    s|<TABLE WIDTH=\"100%\"><TR><TD>||gi; s|</TD></TR></TABLE>||gi;
  109.  
  110.     $c = $ARGV if $c eq '';
  111.     if ($c ne $ARGV) {
  112.        &filename;
  113.        $c = $ARGV; $i=0; $x='';
  114.        do init;
  115.      }
  116.  
  117.         #new sectioned fmt/changed things
  118.    if (!&filtline) {
  119.       next if /\d+\.\d+\.\d+\.\d+ writes:<br>/i    #NO IPs anymore
  120.         || m|^</body>|
  121.         || m|^</html>|;
  122.       $z[$i++] = $_;
  123.          #new sectioned fmt/changed things
  124.          #start skiping/topmost listbox 1st time only
  125.    }
  126. }
  127.  
  128. #for the last one
  129. &filename;
  130.